#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
  

int main(){
	pid_t pid=fork();
	if(pid==-1)exit(1);
    sleep(2);
	if(pid==0){
		printf("fork:%d\n",getpid());
		exit(1000);
	}else{
        int status=0;
		printf("wait\n");
        pid_t cpid=0;
		//while((cpid	=wait(&status))==-1);
        cpid=wait(&status);
		printf("%d %d %d \n",cpid,WIFEXITED(status),WEXITSTATUS(status));
	}
	return 0;
}
